package b.g.b.h.l;

import b.g.b.h.c;
import b.g.b.h.d;
import b.g.b.h.g;
import b.g.b.h.l.f.a;

/* compiled from: VerticalWidgetRun */
public class m extends o {
    public f k;
    public g l;

    public m(d dVar) {
        super(dVar);
        f fVar = new f(this);
        this.k = fVar;
        this.l = null;
        this.h.e = a.TOP;
        this.i.e = a.BOTTOM;
        fVar.e = a.BASELINE;
        this.f = 1;
    }

    public void a(d dVar) {
        d.a aVar = d.a.MATCH_CONSTRAINT;
        int ordinal = this.j.ordinal();
        if (ordinal == 1 || ordinal == 2 || ordinal != 3) {
            int i;
            int i2;
            g gVar = this.e;
            if (gVar.c && !gVar.j && this.d == aVar) {
                d dVar2 = this.b;
                int i3 = dVar2.m;
                g gVar2;
                if (i3 == 2) {
                    d dVar3 = dVar2.P;
                    if (dVar3 != null) {
                        gVar2 = dVar3.e.e;
                        if (gVar2.j) {
                            gVar.c((int) ((((float) gVar2.g) * dVar2.t) + 0.5f));
                        }
                    }
                } else if (i3 == 3) {
                    gVar2 = dVar2.d.e;
                    if (gVar2.j) {
                        float f;
                        float f2;
                        i = dVar2.T;
                        if (i == -1) {
                            f = (float) gVar2.g;
                            f2 = dVar2.S;
                        } else if (i == 0) {
                            f = ((float) gVar2.g) * dVar2.S;
                            i2 = (int) (f + 0.5f);
                            gVar.c(i2);
                        } else if (i != 1) {
                            i2 = 0;
                            gVar.c(i2);
                        } else {
                            f = (float) gVar2.g;
                            f2 = dVar2.S;
                        }
                        f /= f2;
                        i2 = (int) (f + 0.5f);
                        gVar.c(i2);
                    }
                }
            }
            f fVar = this.h;
            if (fVar.c) {
                f fVar2 = this.i;
                if (fVar2.c && !(fVar.j && fVar2.j && this.e.j)) {
                    int i4;
                    if (!this.e.j && this.d == aVar) {
                        d dVar4 = this.b;
                        if (dVar4.l == 0 && !dVar4.x()) {
                            fVar = (f) this.i.l.get(0);
                            i4 = ((f) this.h.l.get(0)).g;
                            fVar2 = this.h;
                            i4 += fVar2.f;
                            ordinal = fVar.g + this.i.f;
                            i = ordinal - i4;
                            fVar2.c(i4);
                            this.i.c(ordinal);
                            this.e.c(i);
                            return;
                        }
                    }
                    if (!this.e.j && this.d == aVar && this.a == 1 && this.h.l.size() > 0 && this.i.l.size() > 0) {
                        i4 = ((f) this.h.l.get(0)).g + this.h.f;
                        ordinal = (((f) this.i.l.get(0)).g + this.i.f) - i4;
                        g gVar3 = this.e;
                        i2 = gVar3.m;
                        if (ordinal < i2) {
                            gVar3.c(ordinal);
                        } else {
                            gVar3.c(i2);
                        }
                    }
                    if (this.e.j && this.h.l.size() > 0 && this.i.l.size() > 0) {
                        f fVar3 = (f) this.h.l.get(0);
                        fVar = (f) this.i.l.get(0);
                        i2 = fVar3.g;
                        f fVar4 = this.h;
                        int i5 = fVar4.f + i2;
                        int i6 = fVar.g;
                        int i7 = this.i.f + i6;
                        float f3 = this.b.a0;
                        if (fVar3 == fVar) {
                            f3 = 0.5f;
                        } else {
                            i2 = i5;
                            i6 = i7;
                        }
                        fVar4.c((int) ((((float) ((i6 - i2) - this.e.g)) * f3) + (((float) i2) + 0.5f)));
                        this.i.c(this.h.g + this.e.g);
                    }
                } else {
                    return;
                }
            }
            return;
        }
        d dVar5 = this.b;
        l(dVar5.E, dVar5.G, 1);
    }

    public void d() {
        d dVar;
        f h;
        f fVar;
        int d;
        d dVar2;
        d.a aVar = d.a.MATCH_PARENT;
        d.a aVar2 = d.a.FIXED;
        d.a aVar3 = d.a.MATCH_CONSTRAINT;
        d dVar3 = this.b;
        if (dVar3.a) {
            this.e.c(dVar3.l());
        }
        if (!this.e.j) {
            this.d = this.b.q();
            if (this.b.y) {
                this.l = new a(this);
            }
            d.a aVar4 = this.d;
            if (aVar4 != aVar3) {
                if (aVar4 == aVar) {
                    dVar = this.b.P;
                    if (dVar != null && dVar.q() == aVar2) {
                        int l = (dVar.l() - this.b.E.d()) - this.b.G.d();
                        b(this.h, dVar.e.h, this.b.E.d());
                        b(this.i, dVar.e.i, -this.b.G.d());
                        this.e.c(l);
                        return;
                    }
                }
                if (this.d == aVar2) {
                    this.e.c(this.b.l());
                }
            }
        } else if (this.d == aVar) {
            dVar = this.b.P;
            if (dVar != null && dVar.q() == aVar2) {
                b(this.h, dVar.e.h, this.b.E.d());
                b(this.i, dVar.e.i, -this.b.G.d());
                return;
            }
        }
        g gVar = this.e;
        boolean z = gVar.j;
        if (z) {
            d dVar4 = this.b;
            if (dVar4.a) {
                c[] cVarArr = dVar4.L;
                if (cVarArr[2].f == null || cVarArr[3].f == null) {
                    if (cVarArr[2].f != null) {
                        h = h(cVarArr[2]);
                        if (h != null) {
                            fVar = this.h;
                            d = this.b.L[2].d();
                            fVar.l.add(h);
                            fVar.f = d;
                            h.k.add(fVar);
                            b(this.i, this.h, this.e.g);
                            dVar = this.b;
                            if (dVar.y) {
                                b(this.k, this.h, dVar.W);
                            }
                        }
                    } else if (cVarArr[3].f != null) {
                        h = h(cVarArr[3]);
                        if (h != null) {
                            fVar = this.i;
                            d = -this.b.L[3].d();
                            fVar.l.add(h);
                            fVar.f = d;
                            h.k.add(fVar);
                            b(this.h, this.i, -this.e.g);
                        }
                        dVar = this.b;
                        if (dVar.y) {
                            b(this.k, this.h, dVar.W);
                        }
                    } else if (cVarArr[4].f != null) {
                        h = h(cVarArr[4]);
                        if (h != null) {
                            fVar = this.k;
                            fVar.l.add(h);
                            fVar.f = 0;
                            h.k.add(fVar);
                            b(this.h, this.k, -this.b.W);
                            b(this.i, this.h, this.e.g);
                        }
                    } else if (!((dVar4 instanceof g) || dVar4.P == null || dVar4.i(c.a.CENTER).f != null)) {
                        dVar = this.b;
                        b(this.h, dVar.P.e.h, dVar.t());
                        b(this.i, this.h, this.e.g);
                        dVar = this.b;
                        if (dVar.y) {
                            b(this.k, this.h, dVar.W);
                        }
                    }
                }
                if (dVar4.x()) {
                    this.h.f = this.b.L[2].d();
                    this.i.f = -this.b.L[3].d();
                } else {
                    h = h(this.b.L[2]);
                    if (h != null) {
                        fVar = this.h;
                        d = this.b.L[2].d();
                        fVar.l.add(h);
                        fVar.f = d;
                        h.k.add(fVar);
                    }
                    h = h(this.b.L[3]);
                    if (h != null) {
                        fVar = this.i;
                        d = -this.b.L[3].d();
                        fVar.l.add(h);
                        fVar.f = d;
                        h.k.add(fVar);
                    }
                    this.h.b = true;
                    this.i.b = true;
                }
                dVar = this.b;
                if (dVar.y) {
                    b(this.k, this.h, dVar.W);
                }
            }
        }
        if (z || this.d != aVar3) {
            gVar.k.add(this);
            if (gVar.j) {
                a(this);
            }
        } else {
            dVar2 = this.b;
            int i = dVar2.m;
            if (i == 2) {
                dVar2 = dVar2.P;
                if (dVar2 != null) {
                    g gVar2 = dVar2.e.e;
                    gVar.l.add(gVar2);
                    gVar2.k.add(this.e);
                    gVar = this.e;
                    gVar.b = true;
                    gVar.k.add(this.h);
                    this.e.k.add(this.i);
                }
            } else if (i == 3 && !dVar2.x()) {
                dVar = this.b;
                if (dVar.l != 3) {
                    gVar = dVar.d.e;
                    this.e.l.add(gVar);
                    gVar.k.add(this.e);
                    gVar = this.e;
                    gVar.b = true;
                    gVar.k.add(this.h);
                    this.e.k.add(this.i);
                }
            }
        }
        dVar = this.b;
        c[] cVarArr2 = dVar.L;
        k kVar;
        if (cVarArr2[2].f != null && cVarArr2[3].f != null) {
            if (dVar.x()) {
                this.h.f = this.b.L[2].d();
                this.i.f = -this.b.L[3].d();
            } else {
                h = h(this.b.L[2]);
                fVar = h(this.b.L[3]);
                h.k.add(this);
                if (h.j) {
                    a(this);
                }
                fVar.k.add(this);
                if (fVar.j) {
                    a(this);
                }
                this.j = o.a.CENTER;
            }
            if (this.b.y) {
                c(this.k, this.h, 1, this.l);
            }
        } else if (cVarArr2[2].f != null) {
            h = h(cVarArr2[2]);
            if (h != null) {
                fVar = this.h;
                int d2 = this.b.L[2].d();
                fVar.l.add(h);
                fVar.f = d2;
                h.k.add(fVar);
                c(this.i, this.h, 1, this.e);
                if (this.b.y) {
                    c(this.k, this.h, 1, this.l);
                }
                if (this.d == aVar3) {
                    dVar = this.b;
                    if (dVar.S > 0.0f) {
                        kVar = dVar.d;
                        if (kVar.d == aVar3) {
                            kVar.e.k.add(this.e);
                            this.e.l.add(this.b.d.e);
                            this.e.a = this;
                        }
                    }
                }
            }
        } else if (cVarArr2[3].f != null) {
            h = h(cVarArr2[3]);
            if (h != null) {
                fVar = this.i;
                d = -this.b.L[3].d();
                fVar.l.add(h);
                fVar.f = d;
                h.k.add(fVar);
                c(this.h, this.i, -1, this.e);
                if (this.b.y) {
                    c(this.k, this.h, 1, this.l);
                }
            }
        } else if (cVarArr2[4].f != null) {
            h = h(cVarArr2[4]);
            if (h != null) {
                fVar = this.k;
                fVar.l.add(h);
                fVar.f = 0;
                h.k.add(fVar);
                c(this.h, this.k, -1, this.l);
                c(this.i, this.h, 1, this.e);
            }
        } else if (!(dVar instanceof g)) {
            dVar2 = dVar.P;
            if (dVar2 != null) {
                b(this.h, dVar2.e.h, dVar.t());
                c(this.i, this.h, 1, this.e);
                if (this.b.y) {
                    c(this.k, this.h, 1, this.l);
                }
                if (this.d == aVar3) {
                    dVar = this.b;
                    if (dVar.S > 0.0f) {
                        kVar = dVar.d;
                        if (kVar.d == aVar3) {
                            kVar.e.k.add(this.e);
                            this.e.l.add(this.b.d.e);
                            this.e.a = this;
                        }
                    }
                }
            }
        }
        if (this.e.l.size() == 0) {
            this.e.c = true;
        }
    }

    public void e() {
        f fVar = this.h;
        if (fVar.j) {
            this.b.V = fVar.g;
        }
    }

    public void f() {
        this.c = null;
        this.h.b();
        this.i.b();
        this.k.b();
        this.e.b();
        this.g = false;
    }

    public boolean k() {
        if (this.d != d.a.MATCH_CONSTRAINT || this.b.m == 0) {
            return true;
        }
        return false;
    }

    public void m() {
        this.g = false;
        this.h.b();
        this.h.j = false;
        this.i.b();
        this.i.j = false;
        this.k.b();
        this.k.j = false;
        this.e.j = false;
    }

    public String toString() {
        StringBuilder g = c.b.a.a.a.g("VerticalRun ");
        g.append(this.b.d0);
        return g.toString();
    }
}
